<template>
  <div class="login-panel">
    <div class="title drag">微信</div>

    <div class="qrcode-container" v-if="!isLogin">
      <div class="scan-title">扫码登录</div>
      <div class="qrcode">
        <!-- <canvas ref="qrcodeCanvas" width="150" height="150"></canvas> -->
        <img
          src="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQFn7zwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyVmZXajhGcG5jTkgxaTNscDFEMUoAAgQT-lhnAwRwFwAA"
          alt=""
          width="250"
          height="250"
        />
      </div>
    </div>

    <div class="login-container" v-else>
      <AvatarBase :width="80" :border-radius="10"></AvatarBase>
      <div class="username">木木</div>
      <el-button type="primary" color="#07c160" style="width: 180px"
        >进入微信</el-button
      >
    </div>

    <div class="panel-bottom">
      <div class="change-account" v-if="isLogin">切换账号</div>
      <div
        class="transform-file"
        :style="{ marginLeft: isLogin ? '20px' : '0' }"
      >
        仅传输文件
      </div>
    </div>
  </div>

  <WinOption
    :show-set-top="false"
    :show-min="false"
    :show-max="false"
  ></WinOption>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
// import QRCode from "qrcode";
import WinOption from '@/components/WinOption.vue';
import AvatarBase from '@/components/avatar/AvatarBase.vue';

// const qrcodeCanvas = ref(null);

const isLogin = ref(false);

onMounted(() => {
  // QRCode.toCanvas(
  //   qrcodeCanvas.value,
  //   "https://example.com",
  //   {
  //     width: 250,
  //     errorCorrectionLevel: "H",
  //   },
  //   (err) => {
  //     if (err) console.error(err);
  //   }
  // );
});
</script>

<style scoped lang="scss">
.login-panel {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: #fff;
  padding: 0px 10px 36px 10px;

  .title {
    width: 100%;
    height: 30px;
    font-size: 15px;
    color: #aeaeb1;
    line-height: 30px;
  }

  .qrcode-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: start;
    align-items: center;
    flex: 1;

    .scan-title {
      font-size: 20px;
      margin-top: 20px;
      color: #07c160;
    }

    .qrcode {
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: start;

      img {
        &:hover {
          cursor: pointer;
        }
      }
    }
  }

  .login-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-top: 35px;
    flex: 1;

    .username {
      font-size: 20px;
      line-height: 105px;
      height: 105px;
      color: #000;
    }
  }

  .panel-bottom {
    width: 100%;
    height: 15px;
    font-size: 15px;
    line-height: 15px;
    color: #5979a1;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;

    .change-account {
      padding-right: 20px;
      border-right: 1px solid #f3f3f3;

      &:hover {
        cursor: pointer;
      }
    }

    .transform-file {
      margin-left: 20px;
      &:hover {
        cursor: pointer;
      }
    }
  }
}
</style>
